FROM maven:3.8.5-openjdk-11

ENV SPRING_HOME=/subfg
ENV DEPLOY_DIR=/subfg/server

WORKDIR $SPRING_HOME
COPY . $SPRING_HOME/target

EXPOSE 8083 8000


RUN mkdir -p $DEPLOY_DIR \
    && apt update \
    && apt install dos2unix -y \
    && apt install wget -y \
    && mv ./target/distribution/subfg-task-0.0.1-SNAPSHOT/* ./server \
    && mv ./target/Dockerfile ./ \
    && rm -rf target \
    && dos2unix $DEPLOY_DIR/bin/server.sh \
    && dos2unix $DEPLOY_DIR/bin/monitor.sh \
    && chmod +x $DEPLOY_DIR/bin/server.sh \
    && chmod +x $DEPLOY_DIR/bin/monitor.sh

ENTRYPOINT ["bash", "-c", "/subfg/server/bin/server.sh start-debug"]